<template>
    <div>
        <h1>登录页面</h1>
        <table class="table table-bordered">
            <tbody>
                 <tr>
                    <td>房型名称</td>
                    <td><input type="text" v-model="info.houseType"></td>
                </tr>
                <tr>
                    <td>房价</td>
                    <td><input type="text" v-model="info.housePrice"></td>
                </tr>
                 <tr>
                    <td>房型图片</td>
                    <td><input type="file" ></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button"  class="btn btn-info" value="登录" @click="login "></td>
                </tr>
            </tbody>
           
        </table>
    </div>
</template>

<script setup lang="ts">
import router from "@/router";
import { useStore } from "@/stores/user";
import axios from "axios";
import { ref,reactive,onMounted } from "vue";

const user=useStore();

let info:any = reactive({
    houseType: "",
    housePrice: '',
    img: "",
    state: 1,
    isDel: 1
})

const login=()=>{
    axios({
        url:'http://localhost:5017/api/User/Login',
        method:"get",
        params:info
    })
    .then(res=>{
        console.log(res);
        if(res.data==-1)
        {
            alert("用户不存在");
            return;
        }
         if(res.data==-2)
        {
            alert("密码错误");
            return;
        }
        alert("登陆成功");
        user.userinfo=res.data;
        router.push('/show');
    })
}


</script>

<style scoped>

</style>